using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Talk : MonoBehaviour
{
    public GameManager _gameManager;

    private void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("space press");
            Collider2D c = NearNPC();
            if (c != null)
            {
                
                var finish=_gameManager.ShowDialog();
                if (finish)
                {
                    _gameManager.enterBattle();
                }
            }
        }
    }

    Collider2D NearNPC()
    {
        
        Collider2D collider2DObj = Physics2D.OverlapCircle(transform.position, 0.5f, LayerMask.GetMask("NPC"));
        Debug.Log("near npc" + collider2DObj + transform.position);
        if (collider2DObj != null && collider2DObj.tag.Equals("Naicy"))
        {
            
            return collider2DObj;
        }

        return null;
    }
}